﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc;
using borkoSi.Models;

namespace borkoSi.Controllers
{
    public class VideoController : Controller
    {

        private borkoSiEntities db = new borkoSiEntities();

        //
        // GET: /Video/

        public ActionResult Index(int? id)
        {

            Videos model = new Videos();

            model.VideosDropdownItems = db.Videos.OrderByDescending(r => r.VideoId).ToList()
                                            .Select(r => new SelectListItem
                                            {
                                                Value = r.VideoId.ToString(),
                                                Text = r.VideoId + " - " + r.VideoName,
                                                Selected = r.VideoId == id ? true : false
                                            });


            ViewBag.FlickrPhotostreamURL = WebConfigurationManager.AppSettings["FlickrPhotostreamURL"].ToString();

            return View(model);

        }

        //
        // GET: /Video/GetVideoLink?id

        public ActionResult GetVideoLink(int id = 1)
        {

            string link = db.Videos.Find(id).VideoLink;

            return Content(link);
        }

    }
}
